<template>
  <div class="buydown">
    
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-goods-action-icon icon="cart-o" text="购物车" />
      <van-goods-action-icon icon="star" text="已收藏" color="#ff5000" />
      <van-goods-action-button type="warning" text="加入购物车" @click="addpro()" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
    
  </div>
</template>

<script>
import {fun_addcart} from '../api/index.js'
import Vue from "vue";
import { Toast } from "vant";
import { GoodsAction, GoodsActionIcon, GoodsActionButton } from "vant";


Vue.use(Toast);
Vue.use(GoodsAction);
Vue.use(GoodsActionButton);
Vue.use(GoodsActionIcon);
export default {
      data(){
        return{
           userid:'',
           proid:'',
           num:1
        }
      },
  methods: {
    onClickIcon() {
      Toast("点击图标");
    },
    onClickButton() {
      Toast("点击按钮");
    },
    addpro(){
      this.proid=this.$route.params.proid,
      this.userid=localStorage.getItem('userid')
      fun_addcart(this.userid,this.proid,this.num).then((res)=>{
           if(res.data.code==200){
            Toast('加入成功')
           }else{
            Toast('加入失败')
           }
      })
    }
  },
  created(){
      console.log(this.$route.params.proid);
  }

};
</script>

<style>
</style>